Repository navigation
feat: add groundwork for an "All" option on dashboard filters - #3830
karl-power wants to merge 1 commit into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🟡 Tier 3 — StandardIntroduces new logic, modifies core functionality, or touches areas with non-trivial risk. Why this tier:
Review process: Full human review — logic, architecture, edge cases. Stats
|
- Add `allowAll` to static list and SQL query filters, and `all: true` to saved variable selections and chart variables - `$__conditionalAll` expands to `1=1` when "All" is selected, matching Grafana; `$__filter` and bare references keep the expanded options - Add `filterSupportsAllValue`, "all" selection helpers, `expandAllSelections` and validation for `allowAll` and saved "all" values - The external API and MCP reject `allowAll` and `all` until the dashboard UI offers "All"
0b6cbdd to
21db794
Compare
|
E2E Test Results✅ All tests passed • 476 passed • 1 skipped • 1083s
Tests ran across 4 shards in parallel. |
Duplicate code analysisNo new duplicate code introduced by this PR. jscpd compared this branch against |
| if (values?.type === 'variable') { | ||
| return { | ||
| included: new Set<string | boolean>(values.values), | ||
| included: new Set<string | boolean>(values.all ? [] : values.values), |
There was a problem hiding this comment.
🟡 P2 — resolveFilterSelection turns an all: true entry into an empty selection, so the app drops "All" whenever any filter changes
rebuildEntries in packages/app/src/hooks/useDashboardFilters.tsx:101-110 re-derives every declared variable's entry from resolveFilterSelection and only writes one back when included.size > 0. An all: true entry now resolves to included(), so it gets dropped. Steps: load ?filters=[{"type":"variable","name":"env","values":[],"all":true}] (the URL parser accepts this because DashboardFilterValueSchema now allows all), then change any other filter, and env's "All" disappears. The new serializer test never covers this path. Fix: carry the all flag through resolveFilterSelection or rebuildEntries, for example by copying parsed.byVariable's all entry over as-is, and add a test that setFilterValue on a sibling filter keeps the all entry.
Advisory. Fix if it is a small defect in code this PR changes; otherwise reply in the thread. Do not widen the PR or touch files it did not already change. How to respond
PR Review
3 finding(s): 🔴 0 P0/P1 · 🟡 2 P2 · 🔵 1 P3 1 posted as inline comment(s) on the changed lines. 1 listed below. 1 P3 folded at the bottom. Findings outside the changed lines
🔵 1 P3 — no action needed before merge
Priority comes from a separate grading pass over the finished review. P3 is folded here instead of posted inline. No finding blocks merge automatically; a maintainer decides. |
Deep Review✅ No critical issues found. This is carefully-scoped groundwork behind an off-switch: the new 🟡 P2 — recommended
🔵 P3 nitpicks (5)
Reviewers (10): correctness, testing, maintainability, project-standards, kieran-typescript, api-contract, adversarial, security, learnings-researcher, agent-native. Testing gaps:
No finding blocks merge automatically. A maintainer will expect P0/P1 findings in code this PR changes to be fixed; P2/P3 are your call -- fix or reply. Never fix findings about surrounding code here; reply instead. Do not widen the PR. How to respond |
Summary
Adds the data model, macro behaviour, helpers and validation for an "All" option on static list and SQL query dashboard filters. Nothing can turn it on yet: there's no UI, and the external API and MCP reject the new fields. Follow-ups add the dropdown option, then enable it for each filter type.
allowAllon static list and SQL query filters opts a filter into offering "All". Multi-select filters only.all: trueon a saved variable selection (savedFilterValuesand thefilters=URL state) records that "All" is selected. Serialization keeps the entry even though it has no values.all: trueonChartVariablemarks "All" for template expansion.expandAllSelectionsfills such a variable'svalueswith its filter's options.$__conditionalAll(cond, $var)expands to1=1when "All" is selected, matching Grafana's ClickHouse plugin.$__filterand bare$varuse the expanded options, ascol IN ($var)does in Grafana.filterSupportsAllValuelimits "All" to filters whose option list the author controls. Query expression and Prometheus label options are capped and scoped to the time range, so "All" could miss values there.validateDashboardFilterFieldGatingrejectsallowAllon a single-select filter.validateDashboardSavedFilterValuesrejectsall: trueon a filter that doesn't offer "All"; it gets wired into the APIs with the UI.allowAllandallfrom its schemas until the dashboard UI offers "All".filterSupportsAllValuemirror the existing source-filter "All" support in EE, so EE can switch to these after the next upstream merge.How to test
cd packages/common-utils && yarn ci:unitmake dev-int FILE='src/routers/external-api/__tests__/dashboards.int.test.ts --testNamePattern=filter.validation'How to test on Vercel preview
N/A — non-UI change
References